package com.day2sockettest;

import java.io.*;
import java.net.ServerSocket;
import java.net.Socket;

public class ServerSocketTest {
    public static void main(String[] args) {
        BufferedReader br = null;
        BufferedWriter bw=null;
        try {
            ServerSocket server = null;
            try {
                server = new ServerSocket(8080);
                System.out.println("服务器启动成功");
            } catch (Exception e) {
                System.out.println("服务器启动出错");
            }
            Socket socket = null;
            try {
                //调用ServerSocket的accept方法，可以接受客户端的请求
                socket = server.accept();
                System.out.println("链接socket成功");
                ServerThread st=new ServerThread(socket);
                st.start();   //服务端接客户端的数据

                //服务端发数据的过程

            } catch (Exception e) {
                e.printStackTrace();
            }
        } finally {
        }
    }
}
